package com.awei.project.model.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 帖子性别枚举
 *
 * @author 小维哥
 * @version 1.2
 */
public enum UserRoleEnum {

    DEFAULT_ROLE("成员", 0),
    ADMIN_ROLE("管理员", 1);

    private final String text;

    private final int value;

    UserRoleEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<Integer> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }
    public static UserRoleEnum getValues(Integer value) {
        if (value == null) {
            return null;
        }
        return Arrays.stream(UserRoleEnum.values())
                .filter(e -> e.getValue()==value)
                .findFirst()
                .orElse(null);
    }

    public int getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
